clear all
set more off
cd "/Users/malet/Dropbox/Contagion paper/Replication files"


set scheme plotplain, permanently 
ssc install coefplot, replace



use "/Users/malet/Dropbox/Contagion paper/Replication files/eurobarometer_final.dta",clear


set more off
* Table 1 and Table A2
ebalance post_fra age age_squared female i.education i.community_type  i.social_class ///
i.personal_situation religiosity i.country, targets(3)
svyset [pweight=_webal]

svy: reg support_constD post_fra i.country 
outreg2 using TAB1.doc, replace ctitle(Specific support) keep(post_fra)  addtext(Country FE, YES)  label  nocon 

svy: reg index post_fra i.country 
outreg2 using TABA2.doc, replace ctitle(Diffuse support) keep(post_fra)  addtext(Country FE, YES) label nocon


ebalance post_fra age age_squared female i.education i.community_type i.social_class ///
i.personal_situation religiosity i.country if date >11 & date < 32, targets(3)
svyset [pweight=_webal]

svy: reg  support_constD post_fra i.country if  date >11 & date < 32
outreg2 using TAB1.doc, append ctitle(Specific support - 10 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 

svy: reg  index post_fra i.country if date >11 & date < 32
outreg2 using TABA2.doc, append ctitle(Diffuse support - 10 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 



ebalance post_fra age age_squared female i.education i.community_type i.social_class ///
i.personal_situation religiosity i.country if date >16 & date < 27, targets(3)
svyset [pweight=_webal]

svy: reg  support_constD post_fra i.country  if date >16 & date < 27
outreg2 using TAB1.doc, append ctitle(Specific support - 5 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 

svy: reg  index post_fra i.country  if date >16 & date < 27
outreg2 using TABA2.doc, append ctitle(Diffuse support - 5 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 






* Figure 4 
* ATT on attitudes towards the EU (coefficient plot)

set more off

ebalance post_fra age age_squared female i.education i.community_type  i.social_class ///
i.personal_situation religiosity i.country, targets(2)
svyset [pweight=_webal]


gen Index = post_fra
svy: reg index Index i.country 
estimates store Index

gen Membership = post_fra
svy: reg membership01 Membership i.country 
estimates store Membership

gen Image = post_fra
svy: reg eu_image01 Image i.country  
estimates store Image

gen Benefit = post_fra 
svy: reg EUbenefit Benefit i.country  
estimates store Benefit

gen Political_Union = post_fra
svy: reg political_union Political_Union i.country  
estimates store Political_Union

gen Importance = post_fra
svy: reg EUrole_importance01 Importance i.country  
estimates store Importance

gen Trust_Parliament = post_fra
svy: reg trust_ep Trust_Parliament i.country  
estimates store Trust_Parliament

gen Trust_Commission = post_fra
svy: reg trust_ec Trust_Commission i.country  
estimates store Trust_Commission

gen Trust_Council = post_fra
svy: reg trust_ceu Trust_Council i.country  
estimates store Trust_Council

gen Satisfaction_EU_democracy = post_fra
svy: reg satdemEU01 Satisfaction_EU_democracy i.country  
estimates store Satisfaction_EU_democracy

gen Euro = post_fra
svy: reg euro Euro i.country 
estimates store Euro

gen Common_Foreign_Policy = post_fra
svy: reg common_foreign Common_Foreign_Policy i.country  
estimates store Common_Foreign_Policy

gen Common_Defence = post_fra
svy: reg common_defence Common_Defence i.country  
estimates store Common_Defence

gen Enlargement = post_fra
svy: reg future_enlargement Enlargement i.country  
estimates store  Enlargement 



coefplot  Political_Union Trust_Commission  Trust_Council Euro Importance    /// 
Trust_Parliament   Enlargement Common_Defence Satisfaction_EU_democracy ///
 Image Common_Foreign_Policy Membership Benefit  Index ///
, keep(Political_Union Trust_Commission  Trust_Council Euro Importance    /// 
Trust_Parliament   Enlargement Common_Defence Satisfaction_EU_democracy ///
 Image Common_Foreign_Policy Membership Benefit  Index ) ///
 xline(0) nooffsets mcolor(blue) ciopts(color(blue))   legend(off) scale(1.5)


** Figure 5 and 6: ATT on mental associations and feelings (coeff plot)
set  more off

gen identity_loss = post_fra
svy: reg mean_identityloss identity_loss i.country 
estimates store identity_loss

gen no_borders = post_fra
svy: reg mean_noborders no_borders i.country 
estimates store no_borders

gen unemployment = post_fra
svy: reg mean_unemployment unemployment i.country 
estimates store unemployment

gen crime = post_fra 
svy: reg mean_crime crime i.country 
estimates store crime

gen money_waste = post_fra
svy: reg mean_wastemoney money_waste i.country
estimates store money_waste

gen bureaucracy = post_fra
svy: reg mean_bureaucracy bureaucracy i.country 
estimates store bureaucracy

gen peace = post_fra
svy: reg mean_peace peace i.country 
estimates store peace

gen prosperity = post_fra
svy: reg mean_prosperity prosperity i.country 
estimates store prosperity

gen democracy = post_fra
svy: reg mean_democracy democracy i.country 
estimates store democracy

gen social_protection = post_fra
svy: reg mean_socialprot social_protection i.country 
estimates store social_protection

gen free_movement = post_fra
svy: reg mean_freetravel free_movement i.country 
estimates store free_movement

gen cultural_diversity = post_fra
svy: reg mean_cultdivers cultural_diversity i.country 
estimates store cultural_diversity

gen strong_say = post_fra
svy: reg mean_strongsay strong_say i.country 
estimates store strong_say

gen hope = post_fra
svy: reg feel_hope hope i.country 
estimates store hope

gen enthusiasm = post_fra
svy: reg feel_enthusiasm enthusiasm i.country 
estimates store enthusiasm

gen trust = post_fra
svy: reg feel_trust trust i.country 
estimates store trust

gen indifference = post_fra
svy: reg feel_indifference indifference i.country 
estimates store indifference

gen anxiety = post_fra
svy: reg feel_anxiety anxiety i.country 
estimates store anxiety

gen mistrust = post_fra
svy: reg feel_mistrust mistrust i.country 
estimates store mistrust

gen rejection = post_fra
svy: reg feel_rejection rejection i.country 
estimates store rejection




coefplot peace free_movement social_protection strong_say      ///
 cultural_diversity democracy prosperity       ///
, keep(peace free_movement social_protection strong_say   cultural_diversity democracy prosperity  ) ///
 xline(0) nooffsets mcolor(blue) ciopts(color(blue))   name(m1) legend(off)  


coefplot bureaucracy  money_waste unemployment  identity_loss   ///
  no_borders  crime     ///
, keep(identity_loss no_borders unemployment crime money_waste bureaucracy ) ///
 xline(0) nooffsets mcolor(blue) ciopts(color(blue))   name(m2) legend(off)  

 graph combine m1 m2, xcommon rows(2) scale(1.5)
 
 
coefplot  anxiety mistrust   rejection  enthusiasm  hope trust  ///
, keep(trust enthusiasm hope rejection mistrust anxiety ) ///
 xline(0) nooffsets mcolor(blue) ciopts(color(blue)) scale(1.5) legend(off)  



* table A1
ebalance post_fra age age_squared female i.education i.community_type i.social_class ///
i.personal_situation religiosity i.country, targets(3)
svyset [pweight=_webal]

svy: oprobit support_const post_fra i.country 
outreg2 using TABA1.doc, replace ctitle(Specific support) keep(post_fra)  addtext(Country FE, YES)  label  nocon 


ebalance post_fra age age_squared female i.education i.community_type i.social_class ///
i.personal_situation religiosity i.country if date >11 & date < 32, targets(3)
svyset [pweight=_webal]

svy: oprobit  support_const post_fra i.country if  date >11 & date < 32
outreg2 using TABA1.doc, append ctitle(Specific support - 10 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 


ebalance post_fra age age_squared female i.education i.community_type i.social_class ///
i.personal_situation religiosity i.country if date >16 & date < 27, targets(3)
svyset [pweight=_webal]

svy: oprobit  support_const post_fra i.country  if date >16 & date < 27
outreg2 using TABA1.doc, append ctitle(Specific support - 5 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 





* Table 2 - ATT on mental associations and feelings

ebalance post_fra age age_squared female i.education i.community_type i.social_class ///
i.personal_situation religiosity i.country, targets(3)
svyset [pweight=_webal]


svy: poisson mean_negative post_fra i.country
outreg2 using TAB2.doc, replace ctitle(Negative associations) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)

svy: poisson mean_positive post_fra i.country 
outreg2 using TAB2.doc, append ctitle(Positive associations) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)

svy: poisson feel_negative post_fra i.country 
outreg2 using TAB2.doc, append ctitle(Negative feelings) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)

svy: poisson feel_positive post_fra i.country 
outreg2 using TAB2.doc, append ctitle(Positive feelings) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)



* Table A3 - Robustness tests
gen missing_EC = 0
replace missing_EC = 1 if support_const==. 


set more off
ebalance post_fra age age_squared female i.education i.community_type i.social_class ///
i.personal_situation religiosity i.country, targets(3)
svyset [pweight=_webal]

svy: reg  missing_EC post_fra i.country 
outreg2 using TAB_A3.doc, replace ctitle(missing ec) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)

svy: reg  support_const pla_fakedate i.country 
outreg2 using TAB_A3.doc, append ctitle(fake date - const) keep(pla_fakedate)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)

svy: reg  index pla_fakedate i.country 
outreg2 using TAB_A3.doc, append ctitle(fake date - ind) keep(pla_fakedate)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)

svy: reg  satdemNAT post_fra i.country 
outreg2 using TAB_A3.doc, append ctitle(sat dem) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)

svy: reg  support_trade post_fra i.country 
outreg2 using TAB_A3.doc, append ctitle(trade) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)

svy: reg knowledge post_fra i.country 
outreg2 using TAB_A3.doc, append ctitle(Knowledge) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)





set more off
* Table A7 and A8 (more covariates: ideology and newspaper readership)
ebalance post_fra age age_squared female i.education i.community_type  i.social_class i.personal_situation religiosity ///
 no_ideology radleft left center right radright i.newspaper i.country, targets(3)
svyset [pweight=_webal]

svy: reg support_constD post_fra i.country 
outreg2 using TABA7.doc, replace ctitle(Specific support) keep(post_fra)  addtext(Country FE, YES)  label  nocon 

svy: reg index post_fra i.country 
outreg2 using TABA8.doc, replace ctitle(Diffuse support) keep(post_fra)  addtext(Country FE, YES) label nocon



ebalance post_fra age age_squared female i.education i.community_type  i.social_class i.personal_situation religiosity ///
 no_ideology radleft left center right radright i.newspaper i.country if date >11 & date < 32, targets(3)
svyset [pweight=_webal]

svy: reg  support_constD post_fra i.country if  date >11 & date < 32
outreg2 using TABA7.doc, append ctitle(Specific support - 10 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 

svy: reg  index post_fra i.country if date >11 & date < 32
outreg2 using TABA8.doc, append ctitle(Diffuse support - 10 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 



ebalance post_fra age age_squared female i.education i.community_type  i.social_class i.personal_situation religiosity ///
 no_ideology radleft left center right radright i.newspaper i.country if date >16 & date < 27, targets(3)
svyset [pweight=_webal]

svy: reg  support_constD post_fra i.country  if date >16 & date < 27
outreg2 using TABA7.doc, append ctitle(Specific support - 5 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 

svy: reg  index post_fra i.country  if date >16 & date < 27
outreg2 using TABA8.doc, append ctitle(Diffuse support - 5 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 




*** exclude countries with high imbalance of treatment/control group
*** i.e. Denmark, Greece, Portugal, Sweden

*use "/Users/malet/Dropbox/Contagion paper/Data/eurobarometer_final.dta",clear


fre country
drop if country== 4 | country== 8 | country== 6 | country== 10


set more off
* table A4 and A5
ebalance post_fra age age_squared female i.education i.community_type  i.social_class ///
i.personal_situation religiosity i.country, targets(3)
svyset [pweight=_webal]

svy: reg support_constD post_fra i.country 
outreg2 using TABA4.doc, replace ctitle(Specific support) keep(post_fra)  addtext(Country FE, YES)  label  nocon 

svy: reg index post_fra i.country 
outreg2 using TABA5.doc, replace ctitle(Diffuse support) keep(post_fra)  addtext(Country FE, YES) label nocon



ebalance post_fra age age_squared female i.education i.community_type i.social_class ///
i.personal_situation religiosity i.country if date >11 & date < 32, targets(3)
svyset [pweight=_webal]

svy: reg  support_constD post_fra i.country if  date >11 & date < 32
outreg2 using TABA4.doc, append ctitle(Specific support - 10 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 

svy: reg  index post_fra i.country if date >11 & date < 32
outreg2 using TABA5.doc, append ctitle(Diffuse support - 10 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 



ebalance post_fra age age_squared female i.education i.community_type i.social_class ///
i.personal_situation religiosity i.country if date >16 & date < 27, targets(3)
svyset [pweight=_webal]

svy: reg  support_constD post_fra i.country  if date >16 & date < 27
outreg2 using TABA4.doc, append ctitle(Specific support - 5 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 

svy: reg  index post_fra i.country  if date >16 & date < 27
outreg2 using TABA5.doc, append ctitle(Diffuse support - 5 days) keep(post_fra)  addtext(Country FE, YES)  label  nocon 





* table A6 cognitive activation

ebalance post_fra age age_squared female i.education i.community_type i.social_class ///
i.personal_situation religiosity i.country, targets(3)
svyset [pweight=_webal]


svy: poisson mean_negative post_fra i.country
outreg2 using TABA6.doc, replace ctitle(Negative associations) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)

svy: poisson mean_positive post_fra i.country 
outreg2 using TABA6.doc, append ctitle(Positive associations) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)

svy: poisson feel_negative post_fra i.country 
outreg2 using TABA6.doc, append ctitle(Negative feelings) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)

svy: poisson feel_positive post_fra i.country 
outreg2 using TABA6.doc, append ctitle(Positive feelings) keep(post_fra)  addtext(Country FE, YES)  label  nocon bd(3) sd(3)




